package com.gnerv.sylvanas.plugin.openapi.autoconfigure;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@AutoConfiguration
@EnableConfigurationProperties(FrameworkOpenapiConfigProperties.class)
public class FrameworkOpenapiAutoConfiguration {

    @Bean
    public OpenAPI openApiDoc() {
        return new OpenAPI()
                .info(new Info()
                        .title("在线接口文档")
                        .version("1.0")
                        .description( "在线接口文档")
                        .license(new License().name("Apache 2.0")));
    }

    @Bean
    public GroupedOpenApi allApi() {
        return GroupedOpenApi.builder()
                .group("default")
                .pathsToMatch("/**")
                .build();
    }

}
